package com.fjh.springboot_01.service.impl;

import com.fjh.springboot_01.mapper.CommentMapper;
import com.fjh.springboot_01.pojo.Comment;
import com.fjh.springboot_01.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class CommentServiceImpl implements CommentService {

    @Autowired
    private CommentMapper commentMapper;

    @Override
    public Comment addComment(Comment comment) {
        comment.setCreateTime(LocalDateTime.now());
        commentMapper.insert(comment);
        return comment;
    }

    @Override
    public List<Comment> getCommentsByLessonId(Integer lessonId) {
        return commentMapper.findByLessonId(lessonId);
    }

    @Override
    public void deleteComment(Integer id) {
        commentMapper.deleteById(id);
    }
} 